package util;

import java.sql.*;

public class DBManager {
    private static String url = "jdbc:mysql://127.0.0.1:3306/uv?serverTimezone=Asia/Shanghai";
    private static String username = "root";
    private static String password = "2004dy";

    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }

    public static Connection getconn(){
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(url,username,password);
        }catch (SQLException e){
            e.printStackTrace();
        }
        return conn;
    }

    public static void close(Connection conn, Statement st, ResultSet rs){
        try{
            if(conn!=null){
                conn.close();
            }
            if(st!=null){
                st.close();
            }
            if(rs!=null){
                rs.close();
            }
        }catch (SQLException e){
            e.printStackTrace();
        }
    }

}